<?php
/**
 * Abstract Factory Pattern	
 * 
 * Abstract class for the Abstract Factory Pattern. 
 *
 * @author		a.buis <a.buis@xs4all.nl>
 */
abstract class Application_Model_Factory_FactoryAbstract implements 
Application_Model_Factory_FactoryInterface
{
	/**
	 * Assign the Factory instances used for this factory.
	 * @param Application_Model_Factory_FactoryInterface $factory
	 */
	public static function setFactory (Application_Model_Factory_FactoryInterface $factory)
	{
		throw new Application_Model_Factory_FactoryException(
			__METHOD__ . ': No implementation of setFactory().'
		);
	}
	/**
	 * Retreive the assigned Factory instance assigned through setFactory().
	 * @return Application_Model_Factory_FactoryInterface
	 */
	public static function getFactory ()
	{
		throw new Application_Model_Factory_FactoryException(
			__METHOD__ . ': No implementation of getFactory().'
		);
	}
	/**
	 * Dynamicly get a method through a string parameter, if this method was not found within the factory's method list an 
	 * Exception will be thrown.
	 * @throws Application_Model_Factory_FactoryException Thrown if method was not found within factory.
	 * @param string $method
	 * @param array $arguments
	 */
	public function get ($method, array $arguments = array())
	{
		$method = 'get' . ucfirst($method);
		if (method_exists($this, $method)) {
			return $this->$method($arguments);
		} else {
			throw new Application_Model_Factory_FactoryException(
				__METHOD__ . ': Invalid method (' . $method . '), this method is not found within the factory methodlist.'
			);
		}
	}
}